// 转换时间戳方法
export function parseTime(time, cFormat) {
  if (arguments.length === 0) {
    return null
  }
  // {h}:{i}:{s}
  const format = cFormat || '{y}-{m}-{d}'
  let date
  if (typeof time === 'object') {
    date = time
  } else {
    if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
      time = parseInt(time)
    }
    if ((typeof time === 'number') && (time.toString().length === 10)) {
      time = time * 1000
    }
    date = new Date(time)
  }
  const formatObj = {
    y: date.getFullYear(),
    m: date.getMonth() + 1,
    d: date.getDate(),
    h: date.getHours(),
    i: date.getMinutes(),
    s: date.getSeconds(),
    a: date.getDay()
  }
  const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
    let value = formatObj[key]
    // Note: getDay() returns 0 on Sunday
    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
    if (result.length > 0 && value < 10) {
      value = '0' + value
    }
    return value || 0
  })
  return time_str
}

/**
 * 手机号码
 * @param {*} s
 */
export function isPhoneNumber(s) {
  return /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(s)
}

/**
 *  本地存储操作
 *  @param { name 名称 value 内容}
 * */ 

 export function setLocations (name, value){
    return  localStorage.setItem(name, JSON.stringify(value))
 }

 export function getLocations ( name ) {
    return  JSON.parse(localStorage.getItem (name))
 }

/**
 * 设置滚动选项
 * */  
export function isSrcoll(){
  return document.querySelector('.content').style.overflow = 'hidden'
}

export function trueSrcoll(){
  return document.querySelector('.content').style.overflow = ''
}